<%@ page import="java.util.*" %>
<%@ page import="java.math.BigDecimal"%>
<%@page import="inet.db.tennis.TennisMatch"%>

<jsp:useBean id="matchDAO" class="inet.db.tennis.TennisMatchDAO" scope="session"/>

<%//@ include file="../include/checklogin.jsp"%>

<%
    String sId = request.getParameter("mid");
    String goal = request.getParameter("goal");
    if (sId == null) sId = "";
    String[] item = sId.split("_");

    try {
        if (item.length == 2) {
            TennisMatch ketqua = matchDAO.getRow(new BigDecimal(item[1]));
            if (ketqua == null) return;

            if ("firstGoal".equalsIgnoreCase(item[0].trim())) {
                ketqua.setFirstScore(Integer.parseInt(goal));
            } else if ("secondGoal".equalsIgnoreCase(item[0].trim())){
            	ketqua.setSecondScore(Integer.parseInt(goal));
            }

            if (matchDAO.updateScore(ketqua)) {
                
            }
        }
    } catch (Exception ex) {
    	System.out.println("scores.jsp: " + ex.getMessage());
    }
%>
